/**
 * Created by cy on 2021/08/05
 * @description 异步加载组件
 */
import Loadable from "react-loadable";
import Loading from '@/components/Loading'


/**
 * @param {*} component
 * @param {*} haveLoading 组件加载时是否有loading效果
 */
const LoadableComponent = (component, haveLoading = false) => {
    return Loadable({
        Loadable: () => component,
        loading: () => {
            if(haveLoading) {
                return <Loading style/>
            }
            return null;
        }
    })
}

export default LoadableComponent;
